<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">
    <div class="col-lg-12">
        <div class="btn-group mb-3" role="group">
            <a role="button" class="btn btn-secondary active" href="<?php echo url('collection-list');?>">采集管理</a>
            <a role="button" class="btn btn-secondary" href="<?php echo url('collection-add');?>">添加采集</a>
        </div>
        <div class="card">
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table" style="min-width: 800px">
                        <thead>
                        <tr>
                            <th width="50">ID：</th>
                            <th width="150">名称</th>
                            <th width="150">最后采集时间</th>
                            <th width="150">内容操作</th>
                            <th width="150">操作</th>
                        </tr>
                        </thead>
                        <tbody id="lists">
                        <?php foreach($lists as $val){ ?>
                        <tr>
                            <td><?php echo $val['id']; ?></td>
                            <td><?php echo $val['name']; ?></td>
                            <td><?php echo $val['lastdate']>0 ? date('Y-m-d H:i:s', $val['lastdate']) : '未采集'; ?></td>
                            <td>
                                [<a href="<?php echo url('collection-urls-'.$val['id']);?>">采集网址</a>]
                                [<a class="collectioncontents" href="<?php echo url('collection-contents-'.$val['id']);?>">采集内容</a>]
                                [<a href="<?php echo url('collection-publist-'.$val['id']);?>">内容发布</a>]
                            </td>
                            <td>
                                [<a href="<?php echo url('collection-publictest-'.$val['id']);?>">测试</a>]
                                [<a href="javascript:void(0);" onclick="copydata(<?php echo $val['id'];?>, '<?php echo $val['name']; ?>');">复制</a>]
                                [<a href="<?php echo url('collection-update-'.$val['id']);?>">修改</a>]
                                [<a href="<?php echo url('collection-delete-'.$val['id']);?>">删除</a>]
                            </td>
                        </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
                <hr class="mt-0" />
            </div>
        </div>
        <nav><ul class="pagination justify-content-center"><?php echo $pagination; ?></ul></nav>
    </div>
</div>
<!-- Modal -->
<div class="modal" id="copydata" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <form action="<?php echo url('collection-copydata');?>" method="post" id="form">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">复制采集规则：</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <input type="hidden" name="id" id="id" />
                <div class="form-group row">
                    <label class="col-sm-4 form-control-label">原采集点名：</label>
                    <div class="col-sm-4" id="oldname"></div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-4 form-control-label">新采集点名：</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="name" />
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">保存</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
    </form>
</div>
<!-- Modal -->
<div class="modal" id="loading" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-body">
                努力采集中...
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>


<script>
    function copydata(id, name) {
        $('#oldname').html(name);
        $('#id').val(id);
        $('#copydata').modal('show');
    }
    $('.collectioncontents').click(function(){
        $('#loading').modal('show');
    })
    $('#nav li.nav-item-collection').addClass('active');
</script>